package review;

//import lev01_beginnerClass.class03_dataStructure.L01_preSum;
import lev01_beginnerClass.util.HelpUtil;

import java.util.Arrays;

public class Review01 {
    public static void main(String[] args) {
        decimalToBinary(7);
//        int[] arr = HelpUtil.generateRandomArr(10, 10);
//        PreSum preSum = new PreSum(arr);
//        System.out.println(Arrays.toString(arr));
//        int rangeSum = preSum.getRangeSum(2, 5);
//        System.out.println(rangeSum);
    }

    public static void decimalToBinary(int num){
        for(int i = 31;i >=0;i--){
            System.out.print((num & (1<<i))==0? 0:1);
        }
        System.out.println();
    }

    public static class PreSum{
        public int[] preSum;

        public PreSum(int[] arr){
            int len = arr.length;
            preSum = new int[len];
            preSum[0] = arr[0];
            for(int i = 1 ;i < len;i++){
                preSum[i] = preSum[i-1]+arr[i];
            }
        }

        public int getRangeSum(int i,int j){
            return i == 0? preSum[j]:preSum[j]-preSum[i-1];
        }
    }
}
